/*
 * Created by JFormDesigner on Sat Apr 23 17:57:02 CST 2022
 */

package View.DefaultCard;

import java.awt.*;
import javax.swing.*;

/**
 * @author dn
 */
public class DefaultPanel extends JPanel {
    ImageIcon icon;
    Image img;

    public DefaultPanel() {
        initComponents();
        //  src/main/resources/welcome.png 是存放在你正在编写的项目的src/main/resources文件夹下的img文件夹下的一个图片
        icon = new ImageIcon("src/main/resources/welcome.png");
        img = icon.getImage();
    }


    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        //下面这行是为了背景图片可以跟随窗口自行调整大小，可以自己设置成固定大小
        g.drawImage(img, 0, 0,this.getWidth(), this.getHeight(), this);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents

        //======== this ========
        setLayout(null);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < getComponentCount(); i++) {
                Rectangle bounds = getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            setMinimumSize(preferredSize);
            setPreferredSize(preferredSize);
        }
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
